home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / AppWannabe / IdleTasks.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-11  |  2.1 KB  |  76 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        IdleTasks.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1990-1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19. /* This function is called when a null event is received.  Do appropriate tasks
  20. ** for null event situations, such as handling balloon help for window. */
  21.  
  22.  
  23.  
  24. /*****************************************************************************/
  25.  
  26.  
  27.  
  28. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  29. #include "App.protos.h"        /* Get the prototypes for application.            */
  30.  
  31.  
  32.  
  33. /*****************************************************************************/
  34. /*****************************************************************************/
  35.  
  36.  
  37.  
  38. #pragma segment Main
  39. void    DoIdleTasks(EventRecord *event)
  40. {
  41. #ifndef __MWERKS__
  42. #pragma unused (event)
  43. #endif
  44.  
  45.     EventRecord        evt;
  46.     WindowPtr        window;
  47.     TEHandle        te;
  48.     Rect            rr;
  49.     KeyMap            kk;
  50.     short            mm;
  51.  
  52.     if (TSMTEAvailable()) TSMEvent(event);
  53.  
  54.     GetKeys(kk);
  55.     mm  = (kk[1] & 0x8000) ? (cmdKey    ) : 0;
  56.     mm |= (kk[1] & 0x0004) ? (optionKey ) : 0;
  57.     mm |= (kk[1] & 0x0008) ? (controlKey) : 0;
  58.     mm |= (kk[1] & 0x0001) ? (shiftKey  ) : 0;
  59.     evt.what      = nullEvent;        /* Make valid null event, with modifiers. */
  60.     evt.modifiers = mm;
  61.     IsCtlEvent(nil, &evt, nil, nil);
  62.  
  63.     window = CTETargetInfo(&te, &rr);
  64.     if (window) {
  65.         if (rr.left < -8192)        /* If TextEdit control is in the frame...  */
  66.             BeginFrame(window);        /* Set clipping to the frame area.           */
  67.         else
  68.             BeginContent(window);    /* Else set clipping to the document area. */
  69.         CTEIdle();
  70.         EndContent(window);            /* EndContent can be used to close a BeginFrame. */
  71.     }
  72. }
  73.  
  74.  
  75.  
  76.